<?php
	function convert_bugID($bugid)
	{
		$convert ="";
		$len = strlen($bugid);
		$delta = 9 - $len;
		for ($i = 0 ;$i < $delta; $i++)
		{
			$convert.= "0";
		}
		$convert.= $bugid;
		return $convert;
	}
	
	function convert_bugID_back($bugid)
	{
		$convert = $bugid + 0;
		return $convert;
	}
	
	function contvert_count_status($count)
	{
		$convert ="";
		$len = strlen($count);
		$delta = 4 - $len;
		for ($i = 0 ;$i < $delta; $i++)
		{
			$convert.= "0";
		}
		$convert.= $count;
		return $convert;
	}

    function convert_num_with_length($num,$length)
    {
        $convert ="";
		$len = strlen($num);
		$delta = $length - $len;
		for ($i = 0 ;$i < $delta; $i++)
		{
			$convert.= "0";
		}
		$convert.= $num;
		return $convert;
    }

    function convert_name ($str)
    {

       $unicode = array(

           'a'=>'á|à|ả|ã|ạ|ă|ắ|ặ|ằ|ẳ|ẵ|â|ấ|ầ|ẩ|ẫ|ậ',

           'd'=>'đ',

           'e'=>'é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ',

           'i'=>'í|ì|ỉ|ĩ|ị',

           'o'=>'ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ',

           'u'=>'ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự',

           'y'=>'ý|ỳ|ỷ|ỹ|ỵ',

           'A'=>'Á|À|Ả|Ã|Ạ|Ă|Ắ|Ặ|Ằ|Ẳ|Ẵ|Â|Ấ|Ầ|Ẩ|Ẫ|Ậ',

           'D'=>'Đ',

           'E'=>'É|È|Ẻ|Ẽ|Ẹ|Ê|Ế|Ề|Ể|Ễ|Ệ',

           'I'=>'Í|Ì|Ỉ|Ĩ|Ị',

           'O'=>'Ó|Ò|Ỏ|Õ|Ọ|Ô|Ố|Ồ|Ổ|Ỗ|Ộ|Ơ|Ớ|Ờ|Ở|Ỡ|Ợ',

           'U'=>'Ú|Ù|Ủ|Ũ|Ụ|Ư|Ứ|Ừ|Ử|Ữ|Ự',

           'Y'=>'Ý|Ỳ|Ỷ|Ỹ|Ỵ',

       );

      foreach($unicode as $nonUnicode=>$uni){

           $str = preg_replace("/($uni)/i", $nonUnicode, $str);

      }

       return $str;

   }

   function _utf8_decode($string)
{
  $tmp = $string;
  $count = 0;
  while (mb_detect_encoding($tmp)=="UTF-8")
  {
    $tmp = utf8_decode($tmp);
    $count++;
  }
  
  for ($i = 0; $i < $count-1 ; $i++)
  {
    $string = utf8_decode($string);
    
  }
  return $string;
  
}

function convert_special_string($str)
{
    $str = preg_replace("/(')/i","&#39;",$str);
    $str = preg_replace("/(\")/i","&#34;",$str);
    return $str;
}


function convert_delete_description($str)
{
  
   $str = preg_replace("/(&#34;)/i","",$str);
   //$str = preg_replace("/(\">)/i","\"/>",$str);
   return $str;
}



?>